<template>
   <header class="header">
      <h1>todos</h1>
      <input class="new-todo" placeholder="请输入任务名称" autofocus  @keyup.enter="addList(value)" v-model.trim="value"/>
    </header>
</template>
 
<script>
export default {
  name: "HmHeader",
  components: {},
  props: {},
  data() {
    return {
      value: '',
    };
  },
  
 
  created() {},
  methods: {
    // 绑定添加事件
    addList(value) {
      // 非空判断
      if(!this.value )  return alert('输入内容不能为空')

      // 向父组件提交事件申请
      this.$emit("addList",value)

      // 输入完清空
      this.value = ""
    }
  }
};
</script>

<style scoped>
     
</style>